package com.jlc.struts2;

import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;

import com.opensymphony.xwork2.ActionSupport;
@Results({
	@Result(name="success", value="/home.jsp"),
	@Result(name="failed", value="/login.jsp"),
	@Result(name="input", value="/login.jsp"),
})

public class AnnotatedLogin extends ActionSupport {
	private String username;
	private String password;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public void validate(){
		if(username==null||username.length()==0){
			addActionError("Username is required");
		}
		if(password==null||password.length()==0){
			addActionError("Password is required");
		}
	}
	public String execute() throws Exception{
		String result="failed";
		if(username.equals(password)){
			result="success";
		}
		return result;
	}

}
